package com.ragdollcat.thirdaicodegenerate.core.saver;

import com.ragdollcat.thirdaicodegenerate.ai.model.HtmlCodeResult;
import com.ragdollcat.thirdaicodegenerate.ai.model.MultiFileCodeResult;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * 保存文件代码执行器
 */
@Slf4j
@Component
public class CodeFileSaverExecutor {

    private static final HtmlCodeFileSaverTemplate HTML_CODE_FILE_SAVER_TEMPLATE = new HtmlCodeFileSaverTemplate();

    private static final MutliFileSaverTemplate MUTLI_FILE_SAVER_TEMPLATE = new MutliFileSaverTemplate();

    @Resource
    private HtmlCodeFileSaverTemplate htmlCodeFileSaverTemplate;

    @Resource
    private MutliFileSaverTemplate mutliFileSaverTemplate;

    public File getCodeFile(Object result, String bizType, Long appId,int version,String description) {
        switch (bizType) {
            case "html" -> {
                return htmlCodeFileSaverTemplate.saveCode((HtmlCodeResult) result,appId,version,description);
//                return HTML_CODE_FILE_SAVER_TEMPLATE.saveCode((HtmlCodeResult) result,appId,version);
            }
            case "multi_file" -> {
                return mutliFileSaverTemplate.saveCode((MultiFileCodeResult) result,appId,version,description);
//                return MUTLI_FILE_SAVER_TEMPLATE.saveCode((MultiFileCodeResult) result,appId,version);
            }
            default -> {
                log.info("该种任务类型：{}不支持！",bizType);
                return null;
            }
        }
    }

}
